package com.gao.stringBuilder;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class StringBuilderDemo {
    /*
            StringBuilder的作用：提高字符串的操作效率
     */
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 100000; i++) {
           stringBuilder.append(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    private static void time() {
        long start = System.currentTimeMillis();
        String s= "";
        for (int i = 0; i < 100000; i++) {
           s+=i;
        }
        System.out.println(s);
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
